package com.wc.alorithm_blue_bridge._模拟.全X数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/1 15:04
 * @description
 * https://www.lanqiao.cn/problems/20138/learning/?problem_list_id=32&page=1
 */
public class Main {
    /**
     * 纯暴力：最多80%, 后续会超时
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static BigInteger[] num = new BigInteger[20];
    static BigInteger P = new BigInteger("998244353");

    public static void main(String[] args) {
        for (int i = 1; i <= 2000; i++) {
            solve(new BigInteger(String.valueOf(i)));
        }
        out.flush();
    }

    static void solve(BigInteger n) {
//        BigInteger n = sc.nextBigInteger();
        for (int i = 0; i <= 10; i++) num[i] = new BigInteger(String.valueOf(i));
        BigInteger cp = num[1];
        boolean exist = false;

        BigInteger res = new BigInteger("-1");
        for (int i = 1; i <= 1000; i++) {
            for (int j = 1; j <= 9; j++) {
                if (n.mod(num[j]).equals(num[0]) && cp.mod(n.divide(num[j])).equals(num[0])) {
                    res = cp.multiply(num[j]);
                    exist = true;
                }
                if (exist) break;
            }
            cp = cp.multiply(num[10]).add(num[1]);
            if (exist) break;
        }
        if (res.compareTo(num[0]) < 0) res = res.mod(P);
        out.println(n + " " + res);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

